/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TimeSeriesGraph.java
 *
 * Created on May 27, 2009, 12:17:00 AM
 */

package grapher;

/**
 *
 * @author Steve Noble
 */

import java.util.List;
import java.awt.Dimension;

import java.awt.PopupMenu;
import java.awt.CheckboxMenuItem;
import java.awt.event.*;

import simframe.simulation.Metric;

class TimeSeriesGraph extends javax.swing.JPanel {

    /** Creates new form TimeSeriesGraph */
     TimeSeriesGraph() {
        initComponents();

         graph = new MetricViewer();

        Dimension minimumSize = new Dimension(0, 0);

        graph.setMinimumSize(minimumSize);

        this.add(graph);


        final PopupMenu popUp = new PopupMenu();

        CheckboxMenuItem item = new CheckboxMenuItem("hello");
        item.setState(true);
        popUp.add(item);

        graph.add(popUp);

        graph.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseReleased(MouseEvent Me) {
                if (Me.isPopupTrigger()) {
                    popUp.show(Me.getComponent(), Me.getX(), Me.getY());
                }
            }
        });

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setPreferredSize(new java.awt.Dimension(200, 240));
        setLayout(new java.awt.BorderLayout());
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    final MetricViewer graph;

    void addMetric(Metric metric) {
        graph.addMetric(metric);
    }

    void clearMetrics() {
        graph.clearMetrics();
    }

    void addDisplay(Metric metric) {
        graph.addDisplay(metric.getName(), java.awt.Color.BLUE);

    }

    void removeDisplay(Metric metric) {
        graph.removeDisplay(metric.getName());
    }

     void update(long t) {
        graph.update(t);
    }
}
